package com.ccsu.joysport.service;


import com.ccsu.joysport.entity.student;
import com.ccsu.joysport.repository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class StudentService {
    @Autowired
    private StudentRepository studentRepository;

    public List<student> getAllStudents() {
        return studentRepository.findAll();
    }

    public Optional<student> getStudentById(String studentNumber) {
        return studentRepository.findById(studentNumber);
    }

    public student saveStudent(student student) {
        return studentRepository.save(student);
    }

    public void deleteStudent(String studentNumber) {
        studentRepository.deleteById(studentNumber);
    }
    public List<student> saveAllStudents(List<student> students) {
        return studentRepository.saveAll(students);
    }
}
